﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using KDPWebPart.MapWebPart;
using WebApp.Controls;
using System.Web;
using System.IO;

namespace KDPWebPart.ControlTemplates.KDPWebPart
{
    public partial class EditorPaneControl : UserControl
    {
        public string WebPartID { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            //MyEditorPart myeditor = (MyEditorPart)this.Parent;
            //KDPMapWebPart webPart = myeditor.GetCurrentWebPart();
            //string modalPanelClientId = ((Panel)webPart.FindControl("pnlModal")).ClientID;
            //string selectStoresPanelClientId = ((Panel)webPart.FindControl("pnlSelectStores")).ClientID;
            //editbutton.Attributes.Add("onClick", "javascript:document.getElementById('" + modalPanelClientId + "').style.width = document.body.clientWidth + 'px';document.getElementById('" + modalPanelClientId + "').style.height = document.body.clientHeight + 'px';document.getElementById('" + modalPanelClientId + "').style.display='block';document.getElementById('" + selectStoresPanelClientId + "').style.display='block';");
            editbutton.Attributes.Add("onClick", string.Format("javascript:window.open('{0}/_layouts/KDPWebPart/EditMapData.aspx?id={1}&url={2}', 'editorWindow','status=1,toolbar=0,menubar=0,resizable=1');", Microsoft.SharePoint.SPContext.Current.Site.Url.ToString(), WebPartID, HttpUtility.UrlEncode(Request.Url.ToString())));
        }

        protected void ctlEditMap_Click(object sender, EventArgs e)
        {
            ;
        }

        internal void Edit(string webPartID)
        {
            //MyEditorPart myeditor = (MyEditorPart)this.Parent;
            //KDPMapWebPart webPart = myeditor.GetCurrentWebPart();
            //Panel p = ((Panel)webPart.FindControl("pnlSelectStores"));
            //WebApp.Controls.MapDataEditor editor = (MapDataEditor)p.Controls[0].FindControl("ctlMapDataEditor");
            //editor.Edit(webPart.GetMapdata());
        }
    }
}
